/**
* 头部菜单
*/ 
<template>
  <!-- <el-menu class="el-menu-demo" mode="horizontal" background-color="#334157" text-color="#fff" active-text-color="#fff">
    <el-button class="buttonimg">
      <span>农产品流通数字化管理服务系统</span>
    </el-button>
  </el-menu> -->
  <div class="header-div">
    <div class="header-logo">
      <span>农产品流通数字化管理服务系统</span>
    </div>
    <div class="right-div fn-clear">
      <i class="close-icon" @click="returnHome"></i>
      <div class="cut-line"></div>
      <p class="user-style">{{ userName }}，您好！</p>
    </div>
  </div>
</template>
<script>
// import { loginout } from '../api/userMG'
export default {
  name: 'navcon',
  data() {
    return {
      userName: '超级管理员',
      collapsed: true,
      imgshow: require('../assets/img/show.png'),
      imgsq: require('../assets/img/sq.png'),
      user: {}
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    this.user = JSON.parse(localStorage.getItem('userdata'))
  },
  methods: {
    // 退出登录
    exit() {
      this.$confirm('退出登录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          setTimeout(() => {
            this.$store.commit('logout', 'false')
            this.$router.push({ path: '/login' })
            this.$message({
              type: 'success',
              message: '已退出登录!'
            })
          }, 1000)
          // loginout()
          //   .then(res => {
          //     if (res.success) {
          //       //如果请求成功就让他2秒跳转路由
          //       setTimeout(() => {
          //         this.$store.commit('logout', 'false')
          //         this.$router.push({ path: '/login' })
          //         this.$message({
          //           type: 'success',
          //           message: '已退出登录!'
          //         })
          //       }, 1000)
          //     } else {
          //       this.$message.error(res.msg)
          //       this.logining = false
          //       return false
          //     }
          //   })
          //   .catch(err => {
          //     // 获取图形验证码
          //     this.getcode()
          //     this.logining = false
          //     this.$message.error('退出失败，请稍后再试！')
          //   })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
    },
    // 切换显示
    toggle(showtype) {
      this.collapsed = !showtype
      this.$root.Bus.$emit('toggle', this.collapsed)
    },
    returnHome()  {}
  }
}
</script>
<style lang="scss" scoped>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
}

.submenu {
  float: right;
}

.buttonimg {
  height: 60px;
  background-color: transparent;
  border: none;
}

.showimg {
  width: 26px;
  height: 26px;
  position: absolute;
  top: 17px;
  left: 17px;
}

.showimg:active {
  border: none;
}

.header-div {
  width: 100%;
  height: 7.8193%;
  background: url(../assets/images/hnfwglxt/header-bg.png) no-repeat;
  background-size: 100% 100%;
  position: relative;

  .header-logo {
    width: 21.04166666%;
    height: 75.55555%;
    background-size: 100% 100%;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    margin-left: 1rem;

    span {
      color: #fff;
      font-size: .7rem;
      font-weight: bold;
    }
  }

  .right-div {
    width: 50%;
    height: .6rem;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 0.93798854%;

    .user-style {
      float: right;
      height: 100%;
      font-size: .475rem;
      font-weight: normal;
      color: #ffffff;
      font-family: 'SourceHanSansCN-Normal';
      margin-top: 0;
    }

    .cut-line {
      float: right;
      width: .025rem;
      height: 100%;
      background: #ffffff;
      margin: 0 1% 0 .5%;
    }

    .close-icon {
      float: right;
      width: .575rem;
      height: 100%;
      background: url(../assets/images/hnfwglxt/close-icon.png) no-repeat;
      background-size: 100% 100%;
      cursor: pointer;
    }
  }
}</style>